﻿#region Legal notice
/*
 * This file is part of EPPLib.
 * Copyright 2010, 2011 
 * Gianluca Esposito (info@gianlucaesposito.it)
 * ----------------------------------------------------------------------------
 * EPPLib is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 * 
 * EPPLib is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with Nome-Programma; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EPPLib.Managers;
using EPPLib.Messages;
using EPPLib.Extra;

namespace EPPWebMVC.Controllers
{
    public class AccreditamentoController : BaseController
    {
        #region Action methods
        [Authorize]
        [HttpGet]
        public ActionResult Index()
        {
            SetBaseViewData();
            return View();
        }
        [Authorize]
        [HttpPost]
        public ActionResult Index(AccreditationCredentials credentials)
        {
            if (ModelState.IsValid)
            {
                Service.UserA = credentials.UsernameA;
                Service.UserB = credentials.UsernameB;
                Service.PasswordA = credentials.PasswordA;
                Service.PasswordB = credentials.PasswordB;
                Service.AccreditationUrl = credentials.Url;
                return RedirectToAction("Step1");
            }
            else
            {
                SetBaseViewData();
                return View();
            }
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step1()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step1(string confirm)
        {
            HelloResponseMessage responseMessage = Service.Hello(CurrentTargetUrl, new HelloMessage());
            SetBaseViewData(responseMessage);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step2()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step2(string confirm)
        {
            LoginMessage requestA = new LoginMessage();
            requestA.Options.Language = "en";
            requestA.RegistrarID = Service.UserA;
            requestA.Password = Service.PasswordA;
            LoginResponseMessage responseA = Service.AccreditationLogin(Service.AccreditationUrl, requestA, ServiceManager.AccreditationUsers.UserA);

            LoginMessage requestB = new LoginMessage();
            requestB.Options.Language = "en";
            requestB.RegistrarID = Service.UserB;
            requestB.Password = Service.PasswordB;
            LoginResponseMessage responseB = Service.AccreditationLogin(Service.AccreditationUrl, requestB, ServiceManager.AccreditationUsers.UserB);

            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_A", responseA);
            SetBaseViewData("__RESPONSE_MESSAGE_B", responseB);

            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step3()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step3(string confirm)
        {
            LogoutMessage request1 = new LogoutMessage();
            LogoutResponseMessage response1 = Service.AccreditationLogout(Service.AccreditationUrl, request1, ServiceManager.AccreditationUsers.UserB);

            LoginMessage request2 = new LoginMessage();
            request2.Options.Language = "en";
            request2.RegistrarID = Service.UserB;
            request2.Password = Service.PasswordB;
            request2.NewPassword = "gianluca12";
            LoginResponseMessage response2 = Service.AccreditationLogin(Service.AccreditationUrl, request2, ServiceManager.AccreditationUsers.UserB);
            Service.PasswordB = request2.NewPassword;

            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            SetBaseViewData("__RESPONSE_MESSAGE_2", response2);

            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step4()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step4(string confirm)
        {
            CheckContactMessage request = new CheckContactMessage();
            request.IDs.Add("AC101980");
            request.IDs.Add("BB101980");
            request.IDs.Add("CC011980");
            request.IDs.Add("DD011980");
            request.IDs.Add("IL101980");
            CheckContactResponseMessage response = Service.AccreditationCheckContact(ServiceManager.AccreditationUsers.UserA, request, string.Empty);
            SetBaseViewData(response);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }
        #endregion

        [Authorize]
        [HttpGet]
        public ActionResult Step5()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step5(string confirm)
        {
            CreateContactMessage request1 = new CreateContactMessage();
            CreateExtendedContactMessage extended1 = new CreateExtendedContactMessage();
            request1.ContactID = "AC101980";
            request1.AuthInfo.Password = "1BAR-foo";
            request1.PostalInfo.Name = "Franco Franchi";
            request1.PostalInfo.Organization = "Ente Pubblico AX";
            request1.PostalInfo.Address.Address = new string[1];
            request1.PostalInfo.Address.Address[0] = "Via dei Condottieri 12";
            request1.PostalInfo.Address.City = "Livorno";
            request1.PostalInfo.Address.District = "LI";
            request1.PostalInfo.Address.CountryCode = "IT";
            request1.PostalInfo.Address.PostalCode = "57100";
            request1.Phone.Number = "+39.0586631212";
            request1.Fax.Number = "+39.0586663131";
            request1.Email = "franco.franchi@ente-ax.it";
            extended1.ConsentForPublishing = true;
            extended1.Registrant.NationalityCode = "IT";
            extended1.Registrant.EntityType = 1;
            extended1.Registrant.TaxCode = "MLSCLL70A01F839L";
            CreateContactResponseMessage response1 = Service.AccreditationCreateContact(ServiceManager.AccreditationUsers.UserA, request1, extended1, string.Empty);

            CreateContactMessage request2 = new CreateContactMessage();
            CreateExtendedContactMessage extended2 = new CreateExtendedContactMessage();
            request2.ContactID = "BB101980";
            request2.AuthInfo.Password = "2fooBAR";
            request2.PostalInfo.Name = "Sandro Rossi";
            request2.PostalInfo.Organization = "Gruppo TNT S.p.A.";
            request2.PostalInfo.Address.Address = new string[1];
            request2.PostalInfo.Address.Address[0] = "via Tritolo 23";
            request2.PostalInfo.Address.City = "Pisa";
            request2.PostalInfo.Address.District = "PI";
            request2.PostalInfo.Address.CountryCode = "IT";
            request2.PostalInfo.Address.PostalCode = "56126";
            request2.Phone.Number = "+39.050311226";
            request2.Fax.Number = "+39.050268298";
            request2.Email = "hurtlocker@tnt.it";
            extended2.ConsentForPublishing = true;
            extended2.Registrant.NationalityCode = "IT";
            extended2.Registrant.EntityType = 1;
            extended2.Registrant.TaxCode = "SLSCVQ56R45F839L";
            CreateContactResponseMessage response2 = Service.AccreditationCreateContact(ServiceManager.AccreditationUsers.UserA, request2, extended2, string.Empty);

            CreateContactMessage request3 = new CreateContactMessage();
            CreateExtendedContactMessage extended3 = new CreateExtendedContactMessage();
            request3.ContactID = "IL101980";
            request3.AuthInfo.Password = "h2o-N2";
            request3.PostalInfo.Name = "Ida Lenzi";
            request3.PostalInfo.Organization = "Ida Lenzi";
            request3.PostalInfo.Address.Address = new string[1];
            request3.PostalInfo.Address.Address[0] = "via San Lorenzo 11";
            request3.PostalInfo.Address.City = "Napoli";
            request3.PostalInfo.Address.District = "NA";
            request3.PostalInfo.Address.CountryCode = "IT";
            request3.PostalInfo.Address.PostalCode = "80100";
            request3.Phone.Number = "+39.0811686789";
            request3.Fax.Number = "+39.0811686789";
            request3.Email = "ida@lenzi.it";
            extended3.ConsentForPublishing = true;
            extended3.Registrant.NationalityCode = "IT";
            extended3.Registrant.EntityType = 1;
            extended3.Registrant.TaxCode = "LNZDIA56R41F839L";
            CreateContactResponseMessage response3 = Service.AccreditationCreateContact(ServiceManager.AccreditationUsers.UserA, request3, extended3, string.Empty);

            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            SetBaseViewData("__RESPONSE_MESSAGE_2", response2);
            SetBaseViewData("__RESPONSE_MESSAGE_3", response3);

            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step6()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step6(string confirm)
        {
            CreateContactMessage request1 = new CreateContactMessage();
            CreateExtendedContactMessage extended1 = new CreateExtendedContactMessage();
            request1.ContactID = "CC011980";
            request1.AuthInfo.Password = "OneTwoThree";
            request1.PostalInfo.Name = "Carlo Conta";
            request1.PostalInfo.Organization = "Unodue srl";
            request1.PostalInfo.Address.Address = new string[1];
            request1.PostalInfo.Address.Address[0] = "Via Po 6";
            request1.PostalInfo.Address.City = "Pisa";
            request1.PostalInfo.Address.District = "PI";
            request1.PostalInfo.Address.CountryCode = "IT";
            request1.PostalInfo.Address.PostalCode = "56100";
            request1.Phone.Number = "+39.050111222";
            request1.Fax.Number = "+39.0503222111";
            request1.Email = "conta@unodue.it";
            extended1.ConsentForPublishing = true;
            CreateContactResponseMessage response1 = Service.AccreditationCreateContact(ServiceManager.AccreditationUsers.UserA, request1, extended1, string.Empty);

            CreateContactMessage request2 = new CreateContactMessage();
            CreateExtendedContactMessage extended2 = new CreateExtendedContactMessage();
            request2.ContactID = "DD011980";
            request2.AuthInfo.Password = "Money-08";
            request2.PostalInfo.Name = "Donald Duck";
            request2.PostalInfo.Organization = "Warehouse Ltd";
            request2.PostalInfo.Address.Address = new string[1];
            request2.PostalInfo.Address.Address[0] = "Warehouse street 1";
            request2.PostalInfo.Address.City = "London";
            request2.PostalInfo.Address.District = "London";
            request2.PostalInfo.Address.CountryCode = "GB";
            request2.PostalInfo.Address.PostalCode = "20010";
            request2.Phone.Number = "+44.2079696010";
            request2.Fax.Number = "+44.2079696620";
            request2.Email = "donald@duck.uk";
            extended2.ConsentForPublishing = true;
            CreateContactResponseMessage response2 = Service.AccreditationCreateContact(ServiceManager.AccreditationUsers.UserA, request2, extended2, string.Empty);

            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            SetBaseViewData("__RESPONSE_MESSAGE_2", response2);

            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step7()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step7(string confirm)
        {
            UpdateContactMessage request1 = new UpdateContactMessage();
            // UpdateExtendedContactMessage extedend1 = new UpdateExtendedContactMessage();
            request1.ContactID = "BB101980";
            request1.ChangeInfo.Fax.Number = "+39.0503128298";
            UpdateContactResponseMessage response1 = Service.AccreditationUpdateContact(ServiceManager.AccreditationUsers.UserA, request1, null, string.Empty);
            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step8()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step8(string confirm)
        {
            InfoContactMessage request1 = new InfoContactMessage();
            request1.ID = "BB101980";
            InfoContactResponseMessage response1 = Service.AccreditationInfoContact(ServiceManager.AccreditationUsers.UserA, request1, string.Empty);
            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step9()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step9(string confirm)
        {
            CheckDomainMessage request1 = new CheckDomainMessage();
            request1.Names.Add("test1980.it");
            request1.Names.Add("test-11980.it");
            CheckDomainResponseMessage response1 = Service.AccreditationCheckDomain(ServiceManager.AccreditationUsers.UserA,  request1, string.Empty);
            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step10()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step10(string confirm)
        {
            CreateDomainMessage request1 = new CreateDomainMessage();
            request1.Name = "test1980.it";
            request1.HostInfo.Hosts.Add(new EPPLib.Objects.HostObject("ns.test.it", "192.168.100.10", EPPLib.Objects.HostAddressObject.AddressTypes.IPv4));
            request1.HostInfo.Hosts.Add(new EPPLib.Objects.HostObject("ns2.test.it", "192.168.100.20", EPPLib.Objects.HostAddressObject.AddressTypes.IPv4));
            request1.HostInfo.Hosts.Add(new EPPLib.Objects.HostObject("ns3.foo.com"));
            request1.Registrant.Code = "AC101980";
            request1.Contacts.Add(new EPPLib.Objects.ContactCodeObject("DD011980", EPPLib.Objects.ContactCodeObject.ContactTypes.Admin));
            request1.Contacts.Add(new EPPLib.Objects.ContactCodeObject("CC011980", EPPLib.Objects.ContactCodeObject.ContactTypes.Tech));
            request1.AuthInfo.Password = "WWW-test-it";

            CreateDomainMessage request2 = new CreateDomainMessage();
            request2.Name = "test-11980.it";
            request2.HostInfo.Hosts.Add(new EPPLib.Objects.HostObject("ns1.foobar.com"));
            request2.HostInfo.Hosts.Add(new EPPLib.Objects.HostObject("ns2.foobar.com"));
            request2.Registrant.Code = "BB101980";
            request2.Contacts.Add(new EPPLib.Objects.ContactCodeObject("DD011980", EPPLib.Objects.ContactCodeObject.ContactTypes.Admin));
            request2.Contacts.Add(new EPPLib.Objects.ContactCodeObject("DD011980", EPPLib.Objects.ContactCodeObject.ContactTypes.Tech));
            request2.AuthInfo.Password = "WWWtest-it";

            CreateDomainResponseMessage response1 = Service.AccreditationCreateDomain(ServiceManager.AccreditationUsers.UserA, request1, string.Empty);
            CreateDomainResponseMessage response2 = Service.AccreditationCreateDomain(ServiceManager.AccreditationUsers.UserA, request2, string.Empty);

            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            SetBaseViewData("__RESPONSE_MESSAGE_2", response2);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step11()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step11(string confirm)
        {
            UpdateDomainMessage request1 = new UpdateDomainMessage();
            request1.Name = "test1980.it";
            request1.AddInfo.Status = new EPPLib.Objects.StatusUpdateObject();
            request1.AddInfo.Status.ClientTransferProhibited = true;
            UpdateDomainResponseMessage response1 = Service.AccreditationUpdateDomain(ServiceManager.AccreditationUsers.UserA, request1, null, string.Empty);
            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step12()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step12(string confirm)
        {
            InfoDomainMessage request1 = new InfoDomainMessage();
            request1.DomainName.Name = "test1980.it";
            InfoDomainResponseMessage response1 = Service.AccreditationInfoDomain(ServiceManager.AccreditationUsers.UserA, request1, string.Empty);
            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step13()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step13(string confirm)
        {
            UpdateDomainMessage request1 = new UpdateDomainMessage();
            request1.Name = "test1980.it";
            request1.RemoveInfo.Hosts.Hosts.Add(new EPPLib.Objects.HostObject("ns2.test.it"));
            UpdateDomainResponseMessage response1 = Service.AccreditationUpdateDomain(ServiceManager.AccreditationUsers.UserA, request1, null, string.Empty);
            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step14()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step14(string confirm)
        {
            UpdateDomainMessage request1 = new UpdateDomainMessage();
            request1.Name = "test1980.it";
            request1.ChangeInfo.AuthInfo.Password = "newwwtest-it";
            request1.ChangeInfo.Registrant.Code = "IL101980";
            UpdateDomainResponseMessage response1 = Service.AccreditationUpdateDomain(ServiceManager.AccreditationUsers.UserA, request1, null, string.Empty);
            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step15()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step15(string confirm)
        {
            TransferDomainMessage request1 = new TransferDomainMessage();
            request1.Name = "test1980.it";
            request1.AuthInfo.Password = "newwwtest-it";

            UpdateDomainMessage request2 = new UpdateDomainMessage();
            request2.Name = "test1980.it";
            request2.RemoveInfo.Status.ClientTransferProhibited = true;

            TransferDomainResponseMessage response1 = Service.AccreditationTransferDomain(ServiceManager.AccreditationUsers.UserB, MessageContainer.Operations.TransferRequest, request1, null, string.Empty);
            UpdateDomainResponseMessage response2 = Service.AccreditationUpdateDomain(ServiceManager.AccreditationUsers.UserA, request2, null, string.Empty);

            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            SetBaseViewData("__RESPONSE_MESSAGE_2", response2);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step16()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step16(string confirm)
        {
            TransferDomainMessage request1 = new TransferDomainMessage();
            request1.Name = "test1980.it";
            request1.AuthInfo.Password = "newwwtest-it";
            TransferExtendedDomainMessage extended1 = new TransferExtendedDomainMessage();

            TransferDomainMessage request2 = new TransferDomainMessage();
            request2.Name = "test1980.it";
            request2.AuthInfo.Password = "newwwtest-it";
            TransferExtendedDomainMessage extended2 = new TransferExtendedDomainMessage();

            TransferDomainResponseMessage response1 = Service.AccreditationTransferDomain(ServiceManager.AccreditationUsers.UserB, MessageContainer.Operations.TransferRequest, request1, extended1, string.Empty);
            TransferDomainResponseMessage response2 = Service.AccreditationTransferDomain(ServiceManager.AccreditationUsers.UserB, MessageContainer.Operations.Query, request1, extended1, string.Empty);

            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            SetBaseViewData("__RESPONSE_MESSAGE_2", response2);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step17()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step17(string confirm)
        {
            PollRequestMessage request1 = new PollRequestMessage();
            TransferDomainMessage request2 = new TransferDomainMessage();
            TransferExtendedDomainMessage extended2 = new TransferExtendedDomainMessage();
            PollAcknowledgmentMessage request3 = new PollAcknowledgmentMessage();
            PollAcknowledgmentMessage request4 = new PollAcknowledgmentMessage();

            PollRequestResponseMessage response1 = Service.AccreditationPollRequest(ServiceManager.AccreditationUsers.UserA, request1, string.Empty);
            TransferDomainResponseMessage response2 = Service.AccreditationTransferDomain(ServiceManager.AccreditationUsers.UserA, MessageContainer.Operations.TransferApprove, request2, extended2, string.Empty);
            BaseResponseMessage response3 = Service.AccreditationPollAcknownledgment(ServiceManager.AccreditationUsers.UserA, string.Empty, string.Empty);
            BaseResponseMessage response4 = Service.AccreditationPollAcknownledgment(ServiceManager.AccreditationUsers.UserA, string.Empty, string.Empty);

            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            SetBaseViewData("__RESPONSE_MESSAGE_2", response2);
            SetBaseViewData("__RESPONSE_MESSAGE_3", response3);
            SetBaseViewData("__RESPONSE_MESSAGE_4", response4);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step18()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step18(string confirm)
        {
            UpdateDomainMessage request1 = new UpdateDomainMessage();
            request1.Name = "test1980.it";
            request1.ChangeInfo.AuthInfo.Password = "BB-29-IT";
            UpdateExtendedDomainMessage extended1 = new UpdateExtendedDomainMessage();
            UpdateDomainResponseMessage response1 = Service.AccreditationUpdateDomain(ServiceManager.AccreditationUsers.UserB, request1, extended1, string.Empty);
            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step19()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step19(string confirm)
        {
            CreateContactMessage request1 = new CreateContactMessage();
            CreateExtendedContactMessage extended1 = new CreateExtendedContactMessage();
            request1.ContactID = "HH10";
            request1.AuthInfo.Password = "h2o-N2";
            request1.PostalInfo.Name = "Ida Lenzi";
            request1.PostalInfo.Organization = "Ida Lenzi";
            request1.PostalInfo.Address.Address = new string[1];
            request1.PostalInfo.Address.Address[0] = "via San Lorenzo 11";
            request1.PostalInfo.Address.City = "Napoli";
            request1.PostalInfo.Address.District = "NA";
            request1.PostalInfo.Address.CountryCode = "IT";
            request1.PostalInfo.Address.PostalCode = "80100";
            request1.Phone.Number = "+39.0811686789";
            request1.Fax.Number = "+39.0811686789";
            request1.Email = "ida@lenzi.it";
            extended1.ConsentForPublishing = true;
            extended1.Registrant.NationalityCode = "IT";
            extended1.Registrant.EntityType = 1;
            extended1.Registrant.TaxCode = "LNZDIA56R41F839L";

            TransferDomainMessage request2 = new TransferDomainMessage();
            request2.Name = "test-11980.it";
            request2.AuthInfo.Password = "WWWtest-it";
            TransferExtendedDomainMessage extended2 = new TransferExtendedDomainMessage();
            extended2.TradeInfo.NewAuthInfo.Password = "HAC6-007";
            extended2.TradeInfo.NewRegistrant.Code = "HH10";

            CreateContactResponseMessage response1 = Service.AccreditationCreateContact(ServiceManager.AccreditationUsers.UserB, request1, extended1, string.Empty);
            TransferDomainResponseMessage response2 = Service.AccreditationTransferDomain(ServiceManager.AccreditationUsers.UserB, MessageContainer.Operations.Request, request2, extended2, string.Empty);

            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            SetBaseViewData("__RESPONSE_MESSAGE_2", response2);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step20()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step20(string confirm)
        {
            PollRequestMessage request1 = new PollRequestMessage();
            TransferDomainMessage request2 = new TransferDomainMessage();
            request2.AuthInfo.Password = "WWWtest-it";
            TransferExtendedDomainMessage extended2 = new TransferExtendedDomainMessage();
            PollRequestResponseMessage response1 = Service.AccreditationPollRequest(ServiceManager.AccreditationUsers.UserA, request1, string.Empty);
            TransferDomainResponseMessage response2 = Service.AccreditationTransferDomain(ServiceManager.AccreditationUsers.UserB, MessageContainer.Operations.TransferApprove, request2, extended2, string.Empty);
            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            SetBaseViewData("__RESPONSE_MESSAGE_2", response2);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step21()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step21(string confirm)
        {
            UpdateDomainMessage request1 = new UpdateDomainMessage();
            request1.AddInfo.Status.ClientUpdateProhibited = true;
            // UpdateExtendedDomainMessage extended1 = new UpdateExtendedDomainMessage();

            InfoDomainMessage request2 = new InfoDomainMessage();
            request2.DomainName.Name = "test-11980.it";
            
            UpdateDomainResponseMessage response1 = Service.AccreditationUpdateDomain(ServiceManager.AccreditationUsers.UserB, request1, null,  string.Empty);
            InfoDomainResponseMessage response2 = Service.AccreditationInfoDomain(ServiceManager.AccreditationUsers.UserB, request2, string.Empty);

            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            SetBaseViewData("__RESPONSE_MESSAGE_2", response2);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step22()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step22(string confirm)
        {
            DeleteDomainMessage request1 = new DeleteDomainMessage();
            request1.Name = "test-11980.it";

            InfoDomainMessage request2 = new InfoDomainMessage();
            request2.DomainName.Name = "test-11980.it";

            DeleteDomainResponseMessage response1 = Service.AccreditationDeleteDomain(ServiceManager.AccreditationUsers.UserB, request1, string.Empty);
            InfoDomainResponseMessage response2 = Service.AccreditationInfoDomain(ServiceManager.AccreditationUsers.UserB, request2, string.Empty);

            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            SetBaseViewData("__RESPONSE_MESSAGE_2", response2);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step23()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step23(string confirm)
        {
            UpdateDomainMessage request1 = new UpdateDomainMessage();
            request1.Name = "test-11980.it";
            UpdateExtendedDomainMessage extended1 = new UpdateExtendedDomainMessage();
            extended1.RestoreInfo.Operation = "test-11980.it";

            UpdateDomainMessage request2 = new UpdateDomainMessage();
            request2.Name = "test1980.it";
            request2.RemoveInfo.Status.ClientDeletedProhibited = true;
            UpdateExtendedDomainMessage extended2 = new UpdateExtendedDomainMessage();


            UpdateDomainResponseMessage response1 = Service.AccreditationUpdateDomain(ServiceManager.AccreditationUsers.UserB, request1, extended1, string.Empty);
            UpdateDomainResponseMessage response2 = Service.AccreditationUpdateDomain(ServiceManager.AccreditationUsers.UserB, request2, extended2, string.Empty);

            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }

        [Authorize]
        [HttpGet]
        public ActionResult Step24()
        {
            SetBaseViewData();
            ViewData["__PRE"] = true;
            ViewData["__POST"] = false;
            return View();
        }

        [Authorize]
        [HttpPost]
        public ActionResult Step24(string confirm)
        {
            DeleteContactMessage request1 = new DeleteContactMessage();
            request1.ID = "AC101980";

            CheckContactMessage request2 = new CheckContactMessage();
            request2.IDs.Add("AC101980");

            DeleteContactResponseMessage response1 = Service.AccreditationDeleteContact(ServiceManager.AccreditationUsers.UserB, request1, string.Empty);
            CheckContactResponseMessage response2 = Service.AccreditationCheckContact(ServiceManager.AccreditationUsers.UserB, request2, string.Empty);

            SetBaseViewData();
            SetBaseViewData("__RESPONSE_MESSAGE_1", response1);
            ViewData["__PRE"] = false;
            ViewData["__POST"] = true;
            return View();
        }
    }
}
